﻿using System;
using System.Net;

namespace FluentPS.Services.Impl
{
    public class SessionService:ISessionService
    {
        #region Consts
        private const string URLPREFIX = "http://";
        private const string PSIPATH = "/_vti_bin/psi/";
        private const string WSSPATH = "/_vti_bin/";
        #endregion

        private CookieContainer _cookies;
        private string _serverName = "localhost";
        private string _pwa = "pwa";

        public SessionService()
        {
        }


        public string PsiBaseUrl
        {
            get
            {
                return URLPREFIX + _serverName + "/" + _pwa + PSIPATH;
            }
        }

        public string WssBaseUrl
        {
            get
            {
                return URLPREFIX + _serverName + "/" + _pwa + WSSPATH;
            }
        }

        public string ServerName
        {
            get
            {
                if (string.IsNullOrEmpty(_serverName))
                    throw new ApplicationException("Empty Server Name");
                return _serverName;
            }
            set
            {
                _serverName = value;
            }
        }

        public string Pwa
        {
            get
            {
                if (string.IsNullOrEmpty(_pwa))
                    throw new ApplicationException("Empty PWA path");
                return _pwa;
            }
            set
            {
                _pwa = value;
            }
        }
    }
}
